package com.ss.android.article.base.feature.detail.presenter;

import com.ss.android.article.base.feature.detail.model.CommentWrapper;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public final class ArticleTabComment {
    public final List<CommentWrapper> commentWrapperList;
    public boolean hasMore;
    public boolean banComment;
    public boolean detailNoComment;
    public int showAddForum;
    public int totalNumber;
    public boolean goTopicDetail;
    public long h;
    public int counter;
    public int offset;
    public boolean hasComment;

    public ArticleTabComment() {
        this.commentWrapperList = new ArrayList();
        this.hasMore = true;
        this.totalNumber = -1;
        this.counter = 0;
        this.offset = 0;
    }

    public final boolean removeComment(long commentId) {
        if (this.commentWrapperList.size() == 0) {
            return false;
        } else {
            Iterator<CommentWrapper> iterator = this.commentWrapperList.iterator();
            do {
                if (iterator.hasNext()) {
                    CommentWrapper commentWrapper = iterator.next();
                    if (commentWrapper.cellType != 1) {
                        continue;
                    }
                    if (commentId != commentWrapper.id) {
                        continue;
                    }
                    break;
                } else {
                    return false;
                }
            } while (true);
            iterator.remove();
            return true;
        }
    }

    public final void copyAllComment(ArticleTabComment articleTabComment) {
        this.copyAllComment(articleTabComment, -1);
    }

    public final void copyAllComment(ArticleTabComment articleTabComment, int cellType) {
        if (articleTabComment != null) {
            if (!this.hasComment) {
                this.hasComment = true;
            }

            Iterator<CommentWrapper> iterator = articleTabComment.commentWrapperList.iterator();
            while (iterator.hasNext()) {
                CommentWrapper commentWrapper = iterator.next();
                if (cellType == -1) {
                    if (this.commentWrapperList.contains(commentWrapper)) {
                        continue;
                    }
                    this.commentWrapperList.add(commentWrapper);
                    continue;
                }

                if (this.commentWrapperList.contains(commentWrapper)) {
                    continue;
                }

                if (commentWrapper.cellType != cellType) {
                    continue;
                }

                this.commentWrapperList.add(commentWrapper);
            }
            this.hasMore = articleTabComment.hasMore;
            this.banComment = articleTabComment.banComment;
            this.showAddForum = articleTabComment.showAddForum;
            this.detailNoComment = articleTabComment.detailNoComment;
            this.totalNumber = articleTabComment.totalNumber;
            this.goTopicDetail = articleTabComment.goTopicDetail;
        }
    }

    public final boolean isEmpty() {
        return !this.hasMore && this.commentWrapperList.size() == 0;
    }

    public final int increateCounter() {
        this.counter++;
        return counter;
    }
}

